package com.five.community.service.impl;

import com.five.community.bean.Repair;
import com.five.community.bean.Village;
import com.five.community.bean.vo.RepairVo;
import com.five.community.mapper.RepairMapper;
import com.five.community.service.RepairService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RepairServiceImpl implements RepairService {

    @Autowired
    private RepairMapper repairMapper;

    @Override
    public List<RepairVo> selectAll() throws Exception {
        return repairMapper.selectAllF();
    }

    @Override
    public List<RepairVo> selectByName(String name) throws Exception {
        return repairMapper.selectByNameF(name);
    }

    @Override
    public void insert(Repair repair) throws Exception {
        repairMapper.insert(repair);
    }

    @Override
    public Repair selectById(long id) throws Exception {
        return repairMapper.selectById(id);
    }

    @Override
    public void update(Repair repair) throws Exception {
        repairMapper.update(repair);
    }

    @Override
    public void delete(long id) throws Exception {
        repairMapper.delete(id);
    }

    @Override
    public PageInfo<RepairVo> getPageInfo(int pageNum, int pageSize) throws Exception {
        //先初始化模型在查询信息顺序不能颠倒
        //初始化分页插件模型
        PageHelper.startPage(pageNum,pageSize);
        //查询所有信息获得列表集合
        List<RepairVo> repairVos = repairMapper.selectAllF();
        //分页模型加入数据
        PageInfo<RepairVo> pageInfo = new PageInfo<>(repairVos);
        //返回分页模型
        return pageInfo;
    }


}
